<include file="../Public/header.html" />
<link href="__PUBLIC__/Css/user.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/Js/user/common.js" charset="UTF-8"></script>

<div id="mainWrapper">

<div id="main">
 	<include file="../User/Tpl/default/Public/user_left_nav_box.html" />
    
    <div id="right_box">
				<div class="item_top">
					<ul>
						<li class="top_bar top-bar-wide top_baron">{$userNavDict[MODULE_NAME][ACTION_NAME]}</li>
					</ul>
				</div>
				<div class="feedBox">
							<!-- 修改交易密码 -->
		          <div class="setItems">
		            <div class="setFold setUnfold" rel="mobile" >
		              <h2>绑定手机</h2>
		            </div>
		            <div style="display: block;" class="setItemsInfo">
		            		<div class="dataR right">
				            		<div class="k_desc_div" style="margin: 0px;">
													<div class="k_icon k_bulb"></div>
													<strong>绑定手机号码</strong>
													<div>
														在此可管理手机号码与当前用户的绑定！
														<br>
														通过手机号码才能查看到好友送来的礼物！
														<br>
														一个手机号只能绑定一个账号，若绑定成功则取消其他账号的绑定！
													</div>
												</div>	
			            	</div>

							      <div id='dobind_area' class="data <php>if( !empty($user['mobile']) ){</php>hidden<php>}</php>" >
								            <ul>
								                <li>
								                    <div class="left alR input_title areal">手机号码：</div>
								                    <div class="left areal">
								                      <div class="left mr5"><input id="mobile" type="text" class="input_text"  /></div>
								                    </div>
								                </li>
								                <li>
								                    <div class="left alR input_title areal">验证码：</div>
								                    <div class="left area2">
								                      	<div class="left mr5">
								                      		<input id="verify" type="text" class="input_text" style="width:125px"/>
															<input type="button" onclick="getBMVCode()" id="btn_get_bmvcode" title="点击获取验证码，验证码将发送到手机！" value="获取" class="btn_w">
														</div>
								                    </div>
								                </li>
								                <li>
								                	<div class="left alR areal">&nbsp;</div>
								                	<div class="left area2">
								                		<input type="button" class="btn_r" value="绑定手机" id="btn_bind_mobile" 
								                			onclick="doBindMobile();" />
								                	</div>

								                </li>
								            </form> 
								           </ul>
							      </div>
							      
							      <div id='binded_area' class="data <php>if( empty($user['mobile']) ){</php>hidden<php>}</php>" >
								            <ul>
								                <li>
								                    <div class="left alR input_title areal">已绑定手机：</div>
								                    <div class="left areal">
								                      <div class="left mr5" style="font-size:14px" id='bindedMobileNo'>{$user['mobile']}</div>
								                    </div>
								                </li>
								                
								                <li>
								                	<div class="left alR areal">&nbsp;</div>
								                	<div class="left area2">
								                		<input type="button" class="btn_r" value="取消绑定" id="btn_unbind_mobile" 
								                		callback="doUnbindMobile()" onclick="ui.confirm(this,'确认取消手机绑定么？');"/>
								                	</div>

								                </li>
								           </ul>
							      </div>
			        	</div>
			        </div><!-- 修改交易密码 end  -->
							<!-- 修改密码 -->
		          <div class="setItems">
		            <div class="setFold setUnfold" rel="base" >
		              <h2>修改密码</h2>
		            </div>
		            <div style="display: block;" class="setItemsInfo">
		            		<div class="dataR right">
			            		<div class="k_desc_div" style="margin: 0px;">
									<div class="k_icon k_bulb"></div>
									<strong>修改密码</strong>
									<div>
										在此可以修改你的登录密码！
									</div>
								</div>	
		            		</div>
							<div class="data">
							
							<php>if(!empty($user['sync_type'])){</php>
								<php>if('sina'==$user['sync_type']){</php>
									<img src="/Public/Images/global/sina24x24.png" align="absmiddle" title="新浪微博直接登录">
								<php>}</php>
								<php>if('douban'==$user['sync_type']){</php>
									<img src="/Public/Images/global/douban24x24.png" align="absmiddle" title="豆瓣直接登录">
								<php>}</php>
								&nbsp;直接登录&nbsp;&nbsp;<a href="javascript:register4Local( '{:U('Index://Public/registerLocal')}' );">转换为系统账号</a>
							<php>}else{</php>
							            <ul>
							                <li>
							                    <div class="left alR input_title areal">原始密码：</div>
							                    <div class="left area2">
							                      <div class="left mr5"><input id="oldpassword" type="password" class="input_text" /></div>
							                    </div>
							                </li>
							                <li>
							                    <div class="left alR input_title areal">新密码：</div>
							                    <div class="left area2">
							                      <div class="left mr5"><input id="password" type="password" class="input_text" /></div>
							                    </div>
							                </li>
							                <li>
							                    <div class="left alR input_title areal">确认密码：</div>
							                    <div class="left area2">
							                      <div class="left mr5"><input id="repassword" type="password" class="input_text" /></div>
							                    </div>
							                </li>
							                <li>
							                	<div class="left alR areal">&nbsp;</div>
							                	<div class="left area2">
							                		<input type="submit" class="btn_r" value="保存修改" 
							                				callback="modifyPassword()" onclick="ui.confirm(this,'确认修改登录密码么？');"
							                				id="btn_modify_pwd"/>
							                	</div>
							                </li>
							           </ul>
							<php>}</php>
							</div>
							      
			        	</div>
			        </div><!-- 修改密码 end  -->
		
							<!-- 修改邮箱-->
		          <div class="setItems">
			            <div class="setFold" rel="email" >
			              <h2>修改邮箱</h2>
			            </div>
			            <div style="display:none;"  class="setItemsInfo">
			            	<div class="dataR right">
				            	<div class="k_desc_div" style="margin: 0px;">
									<div class="k_icon k_bulb"></div>
									<strong>修改邮箱</strong>
									<div>
										在此可修改你的登录邮箱！
										<br>
										确认邮件将放送到新的邮箱中！需手动确认新邮箱，修改才可生效！
										<br>
										详细操作说明见收到的确认邮件！
									</div>
								</div>	
			            	</div>
							<div class="data"><!-- 修改密码 begin  -->
							<php>if(!empty($user['sync_type'])){</php>
								<php>if('sina'==$user['sync_type']){</php>
									<img src="/Public/Images/global/sina24x24.png" align="absmiddle" title="新浪微博直接登录">
								<php>}</php>
								<php>if('douban'==$user['sync_type']){</php>
									<img src="/Public/Images/global/douban24x24.png" align="absmiddle" title="豆瓣直接登录">
								<php>}</php>
								&nbsp;直接登录&nbsp;&nbsp;<a href="javascript:register4Local( '{:U('Index://Public/registerLocal')}' );">转换为系统账号</a>	
							<php>}else{</php>
								            <ul>
								                <li>
								                    <div class="left alR input_title areal">原始Email：</div>
								                    <div class="left areal">
								                      <div class="left mr5"><input id="oldemail" type="text" class="input_text" value="{$user['email']}" readonly/></div>
								                    </div>
								                </li>
								                <li>
								                    <div class="left alR input_title areal">新Email：</div>
								                    <div class="left area2">
								                      <div class="left mr5"><input id="email" type="text" class="input_text" /></div>
								                    </div>
								                </li>
								                <li>
								                	<div class="left alR areal">&nbsp;</div>
								                	<div class="left area2">
								                		<input type="button" class="btn_r" value="保存修改" 
								                		id="btn_modify_email" 
								                		callback="modifyEmail()" onclick="ui.confirm(this,'确认修改注册邮箱地址么？');"/>
								                	</div>
								                </li>
								           </ul>
							<php>}</php>
							</div>
								      
			            </div>
		          </div><!-- 修改邮箱 end  -->
		          
				  		
				  		<!-- 修改交易密码 
		          <div class="setItems">
		            <div class="setFold setUnfold" rel="secret" >
		              <h2>交易密码</h2>
		            </div>
		            <div style="display: block;" class="setItemsInfo">
		            		<div class="dataR right">
				            		<div class="k_desc_div" style="margin: 0px;">
													<div class="k_icon k_bulb"></div>
													<strong>修改交易密码</strong>
													<div>
														朋友送的礼物可能需要交易密码才能使用，在此设置你的交易密码！
													</div>
												</div>	
			            	</div>
							      <div class="data">
							      </div>
			        	</div>
			        </div>
			        -->
			        <!-- 修改交易密码 end  -->
			        
			        <!-- 修改交易密码 -->
		          <div class="setItems">
		            <div class="setFold setUnfold" rel="othersys" >
		              <h2>外部绑定</h2>
		            </div>
		            <div style="display: block;" class="setItemsInfo">
		            	<div class="dataR right">
				            <div class="k_desc_div" style="margin: 0px;">
								<div class="k_icon k_bulb"></div>
								<strong>外部绑定设置</strong>
								<div>
									在此管理与其他系统账号的绑定！
									<br>
									如新浪微博，豆瓣等！绑定后可直接用其他账号登录！
								</div>
							</div>	
			            </div>
						<div class="data">
							<div style="height:40px;width:400px;margin-top: 10px;">
								<php>$loginbinds = model('User')->syncStatus($_SESSION['mid']);</php>
								
								<img src="/Public/Images/global/sina24x24.png" align="absmiddle" title="绑定新浪微博">
								&nbsp;&nbsp;
								<php>if($loginbinds['sina']!=null){</php>
									已绑定新浪微博&nbsp;&nbsp;
									<span style="color: #045FB4;cursor: pointer;" 
										callback="unbindaccount('sina')" onclick="ui.confirm(this,'确认取消绑定么？');"
										title="取消绑定新浪微博！">取消绑定</span>
								<php>}else{</php>
									未绑定新浪微博&nbsp;&nbsp;
									<a href="javascript:void(0);" style="color: #045FB4;cursor: pointer;" onclick="$(this).attr('target','_blank');$(this).attr('href','{$sinaurl}');$(this).click();" 
										title="点击绑定新浪微博，用新浪微博账号登陆！">点击绑定</a>
								<php>}</php>
							</div>
							<div style="height:40px;width:400px;margin-top: 10px;">
								<img src="/Public/Images/global/douban24x24.png" align="absmiddle" title="绑定豆瓣">
								&nbsp;&nbsp;
								<php>if($loginbinds['douban']!=null){</php>
									已绑定豆瓣&nbsp;&nbsp;
									<span style="color: #045FB4;cursor: pointer;" 
										callback="unbindaccount('douban')" onclick="ui.confirm(this,'确认取消绑定么？');"
										title="取消绑定豆瓣！">取消绑定</span>
								<php>}else{</php>
									未绑定豆瓣&nbsp;&nbsp;
									<a href="javascript:void(0);" style="color: #045FB4;cursor: pointer;" onclick="$(this).attr('target','_blank');$(this).attr('href','{$doubanurl}');$(this).click();" 
										title="点击绑定豆瓣，用豆瓣账号登陆！">点击绑定</a>
								<php>}</php>
							</div>
						</div>
			        </div>
			      </div><!-- 修改交易密码 end  -->
		          
		        <div class="c"></div>
		        </div>
		      </div>
  <!-- 右侧内容 end  -->
  <div class="c"></div>
</div>
</div>
<include file="../Public/footer.html" />

<script>
	//$(function(){
		var hs = document.location.hash;
		var _basemodel = 'mobile';
		changeModel( hs.replace('#','') ,_basemodel);
		$('.setFold').click(function(){
			if( $(this).attr('class')=='setFold' ){
				changeModel( $(this).attr('rel'),_basemodel );
			}else{
				$(this).removeClass('setUnfold');
				$(this).next('.setItemsInfo').hide();
			}
			//location.href='#'+$(this).attr('rel');
		});
		
	
	//});
	
	

	function modifyPassword() {
		$('#btn_modify_pwd').attr('disabled','true');
		var oldpassword = $('#oldpassword').val();
		var repassword = $('#repassword').val();
		var password = $('#password').val();
		k_ajaxRequest("{:U('User://Account/doModifyPassword')}",
										{oldpassword:oldpassword,password:password,repassword:repassword},
										function(){ $('#btn_modify_pwd').removeAttr('disabled'); },
										function(){ $('#btn_modify_pwd').removeAttr('disabled'); }
									);
	}

	function modifyEmail() {
		$('#btn_modify_email').attr('disabled','true');
		var oldemail = $('#oldemail').val();
		var email = $('#email').val();
		k_ajaxRequest("{:U('User://Account/modifyEmail')}",
										{oldemail:oldemail,email:email},
										function(){ $('#btn_modify_email').removeAttr('disabled'); },
										function(){ $('#btn_modify_email').removeAttr('disabled'); }
									);
	}
	
	
	function getBMVCode() {
		$('#btn_get_bmvcode').attr('disabled','true');
		var mobile = $('#mobile').val();
		k_ajaxRequest("{:U('User://Account/sendBMVerifyCode')}",
					{mobile:mobile},
					function(){ $('#btn_get_bmvcode').removeAttr('disabled'); },
					function(){ $('#btn_get_bmvcode').removeAttr('disabled'); }
				);
	}
	
	function doBindMobile() {
		$('#btn_bind_mobile').attr('disabled','true');
		var mobile = $('#mobile').val();
		var verify = $('#verify').val();
		k_ajaxRequest("{:U('User://Account/bindMobile')}",
					{mobile:mobile,verify:verify},
					function(){ $('#btn_bind_mobile').removeAttr('disabled');
								$('#bindedMobileNo').html(mobile);
								$('#dobind_area').hide();
								$('#binded_area').show();
								$('#mobile').val('');
								$('#verify').val('');
							  },
					function(){ $('#btn_bind_mobile').removeAttr('disabled'); }
				);
	}
	
	function doUnbindMobile(){
		$('#btn_unbind_mobile').attr('disabled','true');
		k_ajaxRequest("{:U('User://Account/unBindMobile')}",
						null,
						function(){ $('#btn_unbind_mobile').removeAttr('disabled');
									$('#mobile').val('');
									$('#verify').val('');
									$('#binded_area').hide();
									$('#dobind_area').show();
									$('#bindedMobileNo').html('');
								  },
						function(){ $('#btn_unbind_mobile').removeAttr('disabled'); }
					);
	}
	
	function unbindaccount(type_){
		//$('#btn_unbind_mobile').attr('disabled','true');
		k_ajaxRequest("{:U('User://Account/unbindaccount')}",
						{type:type_},
						function(){ k_page_redirect( "{:U('User://Account/security')}#othersys" ); },
						function(){ }
					);
	}
</script>